<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="form-group">
				<label for="exampleInputName2">邮箱地址</label> <input type="text"
					class="form-control" id="phone" placeholder="请输入电子邮箱" />
</div>
<input type="button" id="btn" value="发送验证码" onclick="settime(this),send()" />
 <script type="text/javascript">
        function send(){
            $.ajax({
                url:"sendMessage",
                type:"GET",
                data:"phone="+$("#phone").val(),
                success:function(msg){
                	alert("发送邮件了");
                }
            });
        }
        var countdown=10;
        function settime(val) {
            if (countdown == 0) {
                val.removeAttribute("disabled");
                val.value="免费获取验证码";
                countdown = 10;
                return;
            } else {
                val.setAttribute("disabled", true);
                val.value="重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function() {
                settime(val) },1000)}
    </script>

</body>
</html>